#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int a[N];
int lsh[N];
int b[N];
int bug[N];
int pre[N];
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i],b[i]=a[i];
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++)
        lsh[a[i]]=i;
    for(int i=1;i<=n;i++)
        b[i]=lsh[b[i]],bug[b[i]]++;
    int ans=n;
    pre[1]=bug[1];
    for(int i=2;i<=n;i++){
        pre[i]=pre[i-1]+bug[i];
        int minn=min(bug[i],pre[i-1]);
        ans-=minn;
        pre[i]-=minn;
    }
    cout<<ans<<"\n";
    return 0;
}